package com.zl.pro.controller;

import javax.annotation.Resource;

import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.github.pagehelper.PageInfo;
import com.zl.pro.pojo.CommonResult;
import com.zl.pro.pojo.FundCompany;
import com.zl.pro.service.FundDetailsService;
import com.zl.pro.pojo.FundDetails;
import com.zl.pro.pojo.FundManager;

@RestController
public class FundDetailsController {

	@Resource
	private FundDetailsService fundDetailsService;
	
	@RequestMapping("/funddetails/allfund")
	public CommonResult<FundDetails> findFundDetails(@RequestParam String fund,@RequestParam(defaultValue = "1",value = "pageNum") Integer pageNum,@RequestParam(defaultValue = "10",value = "pageSize") Integer pageSize){
		Object details = fundDetailsService.findFundDetails(fund,pageNum, pageSize);
		CommonResult<FundDetails> result = new CommonResult<FundDetails>();
		result.setResultCode(200);
		result.setResultDatas(details);
	    return result;
	}
	
//查询经理
	@RequestMapping("/funddetails/allmanager")
	public CommonResult<FundManager> findAllManager(@RequestParam String manager,@RequestParam(defaultValue = "1",value = "pageNum") Integer pageNum,@RequestParam(defaultValue = "10",value = "pageSize") Integer pageSize){
		Object managers = fundDetailsService.findAllManager(manager,pageNum, pageSize);
		CommonResult<FundManager> result = new CommonResult<FundManager>();
		result.setResultCode(200);
		result.setResultDatas(managers);
	    return result;
	}
	
	
//查询公司
	
	@RequestMapping("/funddetails/allcompany")
	public CommonResult<FundCompany> findAllCompany(@RequestParam String manager,@RequestParam(defaultValue = "1",value = "pageNum") Integer pageNum,@RequestParam(defaultValue = "10",value = "pageSize") Integer pageSize){
		Object companys = fundDetailsService.findAllCompany(manager,pageNum, pageSize);
		CommonResult<FundCompany> result = new CommonResult<FundCompany>();
		result.setResultCode(200);
		result.setResultDatas(companys);
	    return result;
	}
	
	
//根据id查询单个
	@RequestMapping(value="/funddetails/findone",method=RequestMethod.GET)
	public CommonResult<FundDetails> findOne(@RequestParam(value = "fundDetailsId") Long fundDetailsId){
	       CommonResult<FundDetails> result = new CommonResult<FundDetails>();
	       result.setResultDatas(fundDetailsService.findOne(fundDetailsId));
	       return result;
	}
	
//插入一个基金
	@RequestMapping(value="/funddetails/insertone",method=RequestMethod.GET)
	public CommonResult<FundDetails> insertOne(@RequestBody FundDetails fundDetails) {
		   CommonResult<FundDetails> result = new CommonResult<FundDetails>();
	       result.setResultDatas(fundDetailsService.insertOne(fundDetails));
	       return result;
	}
	
	
//根据基金超市分类查询
	@RequestMapping(value="/funddetails/findbytype",method=RequestMethod.GET)
	public CommonResult<FundDetails> findByType(@RequestParam(value = "fundType") String fundType,@RequestParam(defaultValue = "1",value = "pageNum") Integer pageNum){
	   CommonResult<FundDetails> result = new CommonResult<FundDetails>();
       result.setResultDatas(fundDetailsService.findByType(fundType,pageNum));
       return result;
}
		
}
